<?php
 $session = new CHttpSession;
 $session->open();

$sql = "SELECT t1.code,t1.OrderCashAmount,t1.daytime,t1.dayend,t1.state,t2.name FROM `apay` t1 inner join `config` t2 on t1.OrderNo =t2.id where t1.state=1 and t1.uid=".$session['user_salesmart'][3];
$dbCommand = Yii::app()->db->createCommand($sql);
$model = $dbCommand->queryAll();
if (count($model) > 0) {
    ?>

    <table border="1" cellpadding="0" cellspacing="0" style="width:630px">
        <tbody>
            <tr>
                <td style="text-align: center;">Đơn H&agrave;ng</td>
                <td style="text-align: center;">Loại Quảng C&aacute;o</td>
                <td style="text-align: center;">Ng&agrave;y Mua</td>
                <td style="text-align: center;">Ng&agrave;y kết Th&uacute;c</td>
                <td style="text-align: center;">Thành tiền</td>
                <td style="text-align: center;">Trạng Th&aacute;i</td>
            </tr>
            <?php
            foreach ($model as $item) {
                ?>
                <tr>                   
                    <td><?php echo $item['code'] ?></td>
                    <td><?php echo $item['name'] ?></td>
                    <td><?php echo $item['daytime'] ?></td>
                    <td><?php echo $item['dayend'] ?></td>
                    <td><?php echo number_format($item['OrderCashAmount']) ?></td>
                    <td><?php
                        if ($item['state'] == 1) {
                            echo 'Thành công';
                        } elseif ($item['state'] == 2) {
                            echo 'Kết thúc';
                        } elseif ($item['state'] == 3) {
                            echo 'Hủy';
                        }  else {
                            echo '';
                        }
                        ?></td>
                </tr>
    <?php } ?>
        </tbody>
    </table>
    <?php
} else {
    echo 'Bạn chưa có giao dịch nào';
}
?>